﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<script>
    layui.use(['jquery', 'form', 'laydate', 'common', 'optimizeSelectOption'], function () {
        var form = layui.form,
            $ = layui.$,
            common = layui.common,
            laydate = layui.laydate;
        var keyValue = $.request("keyValue");
        //权限字段
        common.authorizeFields('adminform');

        laydate.render({
            elem: '#F_CallRepairTime'
            , trigger: 'click'
            , type: 'datetime'
            , format: 'yyyy/MM/dd HH:mm:ss',
            value: new Date()
        });

        function randomNumber() {
            var now = new Date();
            var year = now.getFullYear().toString();
            var month = now.getMonth() + 1;
            var day = now.getDate();
            var hour = now.getHours();
            var minutes = now.getMinutes();
            var seconds = now.getSeconds();
            var no = year + month + day + hour + minutes + seconds;
            return no;

        }

        $(function () {
            initControl();
            if (!!keyValue) {
                common.ajax({
                    url: '/EquipmentManage/EqpRepair/GetFormJson',
                    dataType: 'json',
                    data: { keyValue: keyValue },
                    async: false,
                    success: function (data) {
                        common.val('adminform', data);
                    }
                });
            }
            else {
                $('#F_RepairNo').val('wx' + randomNumber());
            }
            form.render();
        });
        wcLoading.close();

        function initControl() {
            layui.$('#F_EqpId').bindSelect({
                url: "/EquipmentManage/EqpPqcCheckItem/GetEqpListJson",
                id: "F_Id",
                text: "F_EqpName"
            });

            //layui.$('#F_ConfirmMan').bindSelect({
            //    url: "/EquipmentManage/EqpRepair/GetUserListJson",
            //    id: "F_Id",
            //    text: "F_RealName"
            //});

            layui.$('#F_CallRepairMan').bindSelect({
                url: "/EquipmentManage/EqpRepair/GetUserListJson",
                id: "F_Id",
                text: "F_RealName"
            });



        }

        form.on('select(CallRepairMan)', function (data) {

            $('#F_CallRepairManName').val($("#F_CallRepairMan option:selected").text());
            form.render();
        });

        form.on('select(splitType)', function (data) {

            $('#F_EqpName').val($("#F_EqpId option:selected").text());
            form.render();
        });

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            var postData = data.field;
            common.submitForm({
                url: '/EquipmentManage/EqpRepair/SubmitForm?keyValue=' + keyValue,
                param: postData,
                success: function () {
                    common.parentreload('data-search-btn');
                }
            })
            return false;
        });
    });
</script>

<body>
    <div class="layuimini-container">
        <div class="layuimini-main">
            <div class="layui-form layuimini-form" lay-filter="adminform">
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label required">维修单号</label>
                    <div class="layui-input-block">
                        <input type="text" id="F_RepairNo" name="F_RepairNo" autocomplete="off" lay-verify="required" placeholder="请输入" class="layui-input" readonly>
                    </div>
                </div>
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label required">工位</label>
                    <div class="layui-input-block">
                        <select id="F_EqpId" name="F_EqpId" lay-filter="splitType" lay-search lay-verify="required">
                            <option value="" selected>请选择</option>
                        </select>
                    </div>
                    <input type="hidden" id="F_EqpName" name="F_EqpName" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label required">故障分类</label>
                    <div class="layui-input-block">
                        <select id="F_ProblemType" name="F_ProblemType" lay-search>
                            <option value="" selected>请选择</option>
                            <option value="1">人</option>
                            <option value="2">机</option>
                            <option value="3">料</option>
                            <option value="4">法</option>
                            <option value="5">环</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label required">故障等级</label>
                    <div class="layui-input-block">
                        <select id="F_ProblemClass" name="F_ProblemClass" lay-search>
                            <option value="" selected>请选择</option>
                            <option value="1">低</option>
                            <option value="2">中</option>
                            <option value="3">高</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label required">故障描述</label>
                    <div class="layui-input-block">
                        <input type="text" id="F_ProblemDesc" name="F_ProblemDesc" autocomplete="off" lay-verify="required" placeholder="请输入" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label">故障图片路径</label>
                    <div class="layui-input-block">
                        <input type="text" id="F_PhotoPath" name="F_PhotoPath" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label required">报修人</label>
                    <div class="layui-input-block">
                        <select id="F_CallRepairMan" name="F_CallRepairMan" lay-verify="required" lay-search lay-filter="CallRepairMan">
                            <option value="" selected>请选择</option>
                        </select>
                        <input type="hidden" id="F_CallRepairManName" name="F_CallRepairManName" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label required">报修时间</label>
                    <div class="layui-input-block">
                        <input type="text" id="F_CallRepairTime" name="F_CallRepairTime" autocomplete="off" lay-verify="required" placeholder="请输入" class="layui-input">
                    </div>
                </div>
                @*<div class="layui-form-item layui-hide">
            <label class="layui-form-label required">派工时间</label>
            <div class="layui-input-block">
                 <input type="text" id="F_DistributeTime" name="F_DistributeTime" autocomplete="off" lay-verify="required" placeholder="请输入" class="layui-input">
            </div>
        </div>
         <div class="layui-form-item layui-hide">
            <label class="layui-form-label required">维修开始时间</label>
            <div class="layui-input-block">
                 <input type="text" id="F_StartRepairTime" name="F_StartRepairTime" autocomplete="off" lay-verify="required" placeholder="请输入" class="layui-input">
            </div>
        </div>
         <div class="layui-form-item layui-hide">
            <label class="layui-form-label required">维修结束时间</label>
            <div class="layui-input-block">
                 <input type="text" id="F_EndRepairTime" name="F_EndRepairTime" autocomplete="off" lay-verify="required" placeholder="请输入" class="layui-input">
            </div>
        </div>*@
         <div class="layui-form-item layui-hide">
            <label class="layui-form-label required">状态</label>
            <div class="layui-input-block">
                <select id="F_Status" name="F_Status" lay-search disabled>
                    <option value="" >请选择</option>
                    <option value="1" selected>报修</option>
                    <option value="2" >已派工</option>
                    <option value="3" >维修中</option>
                    <option value="4" >确认</option>
                    <option value="5" >关闭</option>
                </select>
            </div>
        </div>
         @*<div class="layui-form-item layui-hide">
            <label class="layui-form-label required">确认人ID,同报修人</label>
            <div class="layui-input-block">
                 <input type="text" id="F_ConfirmMan" name="F_ConfirmMan" autocomplete="off" lay-verify="required" placeholder="请输入" class="layui-input">
            </div>
        </div>
         <div class="layui-form-item layui-hide">
            <label class="layui-form-label required">确认时间</label>
            <div class="layui-input-block">
                 <input type="text" id="F_ConfirmTime" name="F_ConfirmTime" autocomplete="off" lay-verify="required" placeholder="请输入" class="layui-input">
            </div>
        </div>
         <div class="layui-form-item layui-hide">
            <label class="layui-form-label required">F_EnabledMark</label>
            <div class="layui-input-block">
                 <input type="text" id="F_EnabledMark" name="F_EnabledMark" autocomplete="off" lay-verify="required" placeholder="请输入" class="layui-input">
            </div>
        </div>
         <div class="layui-form-item layui-hide">
            <label class="layui-form-label required">备注</label>
            <div class="layui-input-block">
                 <input type="text" id="F_Description" name="F_Description" autocomplete="off" lay-verify="required" placeholder="请输入" class="layui-input">
            </div>
        </div>*@

                <div class="layui-form-item layui-hide">
                    <button class="layui-btn site-demo-active" lay-submit id="submit" lay-filter="saveBtn">确认保存</button>
                </div>
            </div>
        </div>
    </div>
</body>

